package top.yxqz.springmvc.msg.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

/**
 * @author: 余小小
 * @date: 2023/4/27
 * @description：全局域对象共享数据
 */
@Controller
@RequestMapping("/msg/app")
public class dataAppController {
    /**
     * uri: /msg/app/
     */
    @GetMapping("/")
    public String methodName(HttpSession session) {
//        通过session对象来获取application域对象
        ServletContext app = session.getServletContext();
        app.setAttribute("name_app", "软件21.6（ServletContext）");
        return "success";
    }
}
